//安环管理系统/环保指标报警管理/当日报警
import React, { Component } from "react";
import { connect } from "dva";
import { Card, Input } from "antd";
import style from "./IndexDayTrend.less";
import { IndexDayTrendQuery } from "../../../services/redmoe";
import PublicService from "../../../services/PublicService";
import moment from "moment";
import IndexDayEcharts from "../sub/IndexDayEcharts";
class IndexDayTrend extends Component {
    state = {
        IndexDayData: []
    };

    //进入页面事件
    componentDidMount() {
        PublicService.getCookie("IndexDayKind");
        PublicService.getCookie("IndexDayTime");
        PublicService.getCookie("IndexDayName");
        PublicService.getCookie("IndexDayhourValue");
        PublicService.getCookie("IndexDaymaxHigh");

        let taTime = Number(PublicService.getCookie("IndexDayTime"));
        let data = {
            takeTime: moment(taTime).format("YYYY-MM-DD HH:mm:ss"),
            typeCode: PublicService.getCookie("IndexDayKind"),
            maxValue: PublicService.getCookie("IndexDaymaxHigh")
        };
        IndexDayTrendQuery({ ...data }).then(data => {
            console.log(data);
            this.setState({
                IndexDayData: data.data.ret
            });
        });
    }

    render() {
        return (
            <div>
                <Card className={style.CardTop}>
                    <div className={style.Top}>
                        指标名称:
                        <Input
                            size="small"
                            disabled={true}
                            style={{
                                width: 100,
                                marginRight: 10,
                                marginLeft: 3
                            }}
                            value={
                                PublicService.getCookie("IndexDayName")
                                    ? PublicService.getCookie("IndexDayName")
                                    : ""
                            }
                        />
                        报警时间:
                        <Input
                            size="small"
                            disabled={true}
                            style={{
                                width: 100,
                                marginRight: 10,
                                marginLeft: 3
                            }}
                            value={
                                moment(
                                    Number(
                                        PublicService.getCookie("IndexDayTime")
                                    )
                                ).format("YYYY-MM-DD")
                                    ? moment(
                                          Number(
                                              PublicService.getCookie(
                                                  "IndexDayTime"
                                              )
                                          )
                                      ).format("YYYY-MM-DD")
                                    : ""
                            }
                        />
                        小时均值:
                        <Input
                            size="small"
                            disabled={true}
                            style={{
                                width: 100,
                                marginRight: 10,
                                marginLeft: 3
                            }}
                            value={
                                PublicService.getCookie("IndexDayhourValue")
                                    ? PublicService.getCookie(
                                          "IndexDayhourValue"
                                      )
                                    : ""
                            }
                        />
                        排放量限值:
                        <Input
                            size="small"
                            disabled={true}
                            style={{
                                width: 100,
                                marginRight: 10,
                                marginLeft: 3
                            }}
                            value={
                                PublicService.getCookie("IndexDaymaxHigh")
                                    ? PublicService.getCookie("IndexDaymaxHigh")
                                    : ""
                            }
                        />
                    </div>
                </Card>
                <Card className={style.CardBottom}>
                    <IndexDayEcharts IndexDayData={this.state.IndexDayData} />
                </Card>
            </div>
        );
    }
}

export default connect()(IndexDayTrend);
